﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace IMeiWeiWebService.Providers
{
    public class BusinessClassProvider
    {
        IMeiWei.BLL.businesstype bll_businessType = new IMeiWei.BLL.businesstype();
        IMeiWei.BLL.businesstypeclassone bll_classOne = new IMeiWei.BLL.businesstypeclassone();
        IMeiWei.BLL.businesstypeclasstwo bll_classTwo = new IMeiWei.BLL.businesstypeclasstwo();
        public List<IMeiWei.Model.businesstype> LoadBusinessTypes()
        {
            return bll_businessType.GetModelList(" 1 = 1");
        }

        public List<IMeiWei.Model.businesstypeclassone> LoadClassOneItems(string businessTypeId)
        {
            return bll_classOne.GetModelList("BusinessType_Id = '" + businessTypeId + "'");
        }

        public string SaveBusinessClassOne(string businessTypeId, string id, string classOneItem)
        {
            IMeiWei.Model.businesstypeclassone model_classOne = new IMeiWei.Model.businesstypeclassone();

            model_classOne.BusinessType_Id = businessTypeId;
            model_classOne.ClassOneItem = classOneItem;
            model_classOne.ClassOneItemStatus = "ACTIVE";
            model_classOne.CreateBy = "SYSTEM_SET";
            model_classOne.CreateTime = DateTime.Now;
            model_classOne.ModifyBy = "SYSTEM_SET";
            model_classOne.ModifyTime = DateTime.Now;
            model_classOne.Id = id;

            bll_classOne.Add(model_classOne);

            return "SUCCESS";
        }

        public string DeleteBusinessClassOne(string id)
        {
            bll_classOne.Delete(id);

            return "SUCCESS";
        }

        public List<IMeiWei.Model.businesstypeclasstwo> LoadClassTwoItems(string businesstypeclassOneId)
        {
            return bll_classTwo.GetModelList("BusinessTypeClassOne_Id = '" + businesstypeclassOneId + "'");
        }

        public List<IMeiWei.Model.businesstypeclasstwo> LoadClassTwoItems()
        {
            return bll_classTwo.GetModelList("1='1'");
        }

        public string SaveBusinessClassTwo(string id, string businesstypeclassOneId, string businessTypeClassTwoName)
        {
            IMeiWei.Model.businesstypeclasstwo model_classTwo = new IMeiWei.Model.businesstypeclasstwo();

            model_classTwo.BusinessTypeClassOne_Id = businesstypeclassOneId;
            model_classTwo.BusinessTypeClassTwoName = businessTypeClassTwoName;
            model_classTwo.BusinessTypeClassTwoStatus = "ACTIVE";
            model_classTwo.CreateBy = "SYSTEM_SET";
            model_classTwo.CreateTime = DateTime.Now;
            model_classTwo.ModifyBy = "SYSTEM_SET";
            model_classTwo.ModifyTime = DateTime.Now;
            model_classTwo.Id = id;

            bll_classTwo.Add(model_classTwo);

            return "SUCCESS";;
        }

    }
}